{extends file="../acp.html"}

{block name="title"}{$head_title}
{/block}
{block name="content"}
<script>
    function no_pic(obj) {
        obj.setAttribute("src", "/Public/Images/acp/nopicture.jpg");
    }
</script>

<div class="tablesWrap">
    <div class="tables-searchbox">
        <form method="post">
            <span class="tbs-txt">资讯分类名称：</span>
            <input type="text" name="information_type_name" value="{$article_sort_name}">

            <!--  <span class="tbs-txt">{$ITEM_NAME}货号：</span>
              <input type="text" class="mini" name="item_sn" value="{$item_sn}">
  -->
            <!--
            <span class="tbs-txt">销售量：</span>
            <input type="text" style="width:60px;" name="start_sales_num" value="{$start_sales_num}">
            <span class="tbs-txt">——</span>
            <input type="text" style="width:60px;" name="end_sales_num" value="{$end_sales_num}">
            -->

          <!--  <select name="incubator_type" id="incubator_type">
                <option value="-1" selected>-是否热门-</option>
                <option value="1" {if $information_type == 1} selected {/if}>是</option>
                <option value="0" {if $information_type == 0} selected {/if}>否</option>
            </select>-->

            <!-- <select name="park_type" id="park_type">
                 <option value="0" selected="">-是否银江自有-</option>
                 <option value="1" {if $park_type == 1} selected {/if}>银江自有园区</option>
                 <option value="2" {if $park_type == 2} selected {/if}>其他园区</option>
             </select>-->

            <!-- <span class="tbs-txt">添加时间：</span>
             <input type="text" autocomplete="off" class="Wdate" name="start_date" value="{$start_date|date_format:'%Y-%m-%d'}"  onclick="WdatePicker()">
             <span class="tbs-txt">至</span>
             <input type="text" autocomplete="off" class="Wdate" name="end_date" value="{$end_date|date_format:'%Y-%m-%d'}"  onclick="WdatePicker()">-->
            <input type="hidden" name="opt" value="select">
            <button type="submit" class="btn"><i class="gicon-search"></i>搜索</button>
            <!--        <button type="button" class="btn" style="background-color:#FF9900;color:#FFF" onclick="sync_item();">同步商品资料</button>-->


        </form>
    </div>
    <!-- end tables-searchbox -->
    <table class="wxtables">
        <colgroup>
            <col width="10%">
            <col width="10%">
            <col width="10%">
            <!--<col width="10%">
            <col width="10%">
            <col width="10%">
            <col width="10%">-->
        </colgroup>
        <thead>
        <tr>
            <td>选择</td>
            <td>分类名</td>
          <!--  <td>资讯名</td>
            <td>是否热门</td>
            <td>排序号</td>
            <td>操作时间</td>-->
            <td>操作</td>
        </tr>
        </thead>
        <tbody>
        {foreach from=$information_type_list item=information }
        <tr>
            <td><input type="checkbox" class="checkbox" value="{$information.article_sort_id}" name="checkIds[]"></td>
            <td>{$information.article_sort_name}</td>
          <!--  <td>
                <div class="gallery">
                    <div><a href="{$information.path_img}"><img src="{$information.path_img}" style="width:70px;display:block;"/></a></div>
                    <div class="clear"></div>
                </div>
                &lt;!&ndash;<a href="{$item.link_item}" target="_blank"><img src="{$item.small_img}" alt="" width="50" height="50" onerror="no_pic(this);"></a>&ndash;&gt;
            </td>
            <td>{$information.title}</td>
            <td>{if $information.isuse==1}是{else}否{/if}</td>
            <td>{$information.serial}</td>
            <td>{$information.time}</td>-->
            <td>
                <a href="/AcpInformation/edit_information_type/information_type_id/{$information.article_sort_id}" class="btn" title="编辑">编辑</a>
                <a  class="btn" title="删除"onclick="del_information_type({$information.article_sort_id})">删除</a>
            </td>
        </tr>
        {foreachelse}
        <tr><td colspan="10">没有找到任何记录</td></tr>
        {/foreach}
        </tbody>
    </table>
    <!-- end wxtables -->
    <div class="tables-btmctrl clearfix">
        <div class="fl">
            <a href="javascript:selall()" class="btn btn-blue">全选</a>
            <a href="javascript:clearall()" class="btn btn-blue">取消</a>
            <a href="javascript:;" class="btn btn-blue " onclick="delInformationTypeBatch()">删除</a>
        </div>
        <div class="fr">
            <div class="paginate">
                {$page->show()}
            </div>
            <!-- end paginate -->
        </div>
    </div>
    <!-- end tables-btmctrl -->
</div>
<!-- end tablesWrap -->
{/block}

{block name="js"}
<script src="/Public/Plugins/My97DatePicker/WdatePicker.js?version={$version}"></script>
<script src="__ACPJS__/acp_item.js?version={$version}"></script>
<script src="__ACPJS__/AcpItem/list_item.js?version={$version}"></script>
<script src="__JS__/front/jquery.showLoading.min.js?version={$version}"></script>
<script src="__JS__/clipboard.min.js"></script>
<link rel="stylesheet" href="__CSS__/front/showLoading.css?version={$version}">
{literal}
<script>
    var item_name = '{$ITEM_NAME}';

    function sync_item()
    {
        var html = "确定执行此操作，本操作将比较费时，请耐心等候!";
        $.jPops.custom({
            title:"同步商品资料",
            content:html,
            okBtnTxt:"确定",
            cancelBtnTxt:"取消",
            callback:function(r)
            {
                if(r)
                {
                    $('body').showLoading();
                    $.post('/Global/sync',{},function(data) {
                        $("body").hideLoading();
                        if (data == 'success') {
                            alert('同步成功');
                            location.reload();
                        } else {
                            alert('同步失败，请稍后再试');
                        }
                    });
                }
                return true;
            }
        });
    }
    //复制商品链接
    function item_link(item_id, is_integral)
    {
        if(is_integral == 1){
            action = 'integral_item_detail';
        }else{
            action = 'item_detail';
        }
        var link = 'http://' + document.domain + '/FrontMall/'+action+'/item_id/' + item_id;
        $.jPops.custom({
            title:"请复制链接",
            content:'<div>商品链接：' + link + '</div>',
            okBtnTxt:"复制",
            cancelBtnTxt:"关闭",
            callback:function(r)
            {
                if(r)
                {
                    text = link;
                    copy_text('jpops-btn-ok');
                }
                else
                {
                    return true;
                }
            }
        });
    }
    function del_information_type(information_type_id)
    {
        var html = "确认删除这个资讯类型";
        $.jPops.custom({
            title:"确认删除",
            content:html,
            okBtnTxt:"确定",
            cancelBtnTxt:"取消",
            callback:function(r)
            {
                if(r)
                {
                    $.post('/AcpInformation/del_information_type',{'information_type_id':information_type_id},function(data) {
                        console.log(data)
                        if (data == 'success') {
                            alert('删除成功');
                            location.reload();
                        } else {
                            alert('删除失败，请稍后再试');
                        }
                    });
                }
                return true;
            }
        });
    }
    //批量删除
    function delInformationTypeBatch(){
        var ids='';
        var count='';
        $('input[name="checkIds[]"]:checked').each(function()
        {
            count ++;
            ids += $(this).val() + ',';
        });
        console.log(ids);
        if(count== 0){
            $.jPops.alert({
                title:"提示",
                content:'对不起，请选择要删除项！',
                okBtnTxt:"确定",
                callback:function(){
                    return true;
                }
            });
            return false;
        }
        $.jPops.confirm({
            title:"提示",
            content:'您确定要删除这些数据吗？',
            okBtnTxt:"确定",
            cancelBtnTxt:"取消",
            callback:function(r){
                if(r){
                    $.ajax({
                        url: '/AcpInformation/delInformationTypeBatch',
                        data: {id: ids},
                        type:'post',
                        success: function(data){
                            console.log(data)
                            if(data == 'success'){
                                $.jPops.alert({
                                    title:"提示",
                                    content:'删除成功',
                                    okBtnTxt:"确定",
                                    callback:function(){
                                        window.location.reload();
                                    }
                                });
                            }else{
                                $.jPops.alert({
                                    title:"提示",
                                    content:'删除失败',
                                    okBtnTxt:"确定",
                                    callback:function(){
                                        return true;
                                    }
                                });
                            }
                        }
                    });
                }
                return true;
            }
        });
    }
    function copy_text(id)
    {
        var clipboard = new Clipboard('#' + id, {
            text: function() {
                return text;
            }
        });

        clipboard.on('success', function(e) {
            console.log(e);
            alert('复制成功');
        });

        clipboard.on('error', function(e) {
            console.log(e);
            alert('复制失败，请手动复制');
        });
    }
</script>
{/literal}
{/block}
